import axios from 'axios'
export default function({ req, res }) {
  // 这里做了服务端和客户端获取cookie的解析
  const cookies = {}
  try {
    req.headers &&
      req.headers.cookie.split(';').forEach(function(cookie) {
        const parts = cookie.match(/(.*?)=(.*)$/)
        cookies[parts[1].trim()] = (parts[2] || '').trim()
      })
    axios.defaults.cookies = cookies
    return cookies
  } catch (error) {}
}
